import Vue from 'vue';
import Vuex from 'vuex';
import axios from 'axios'
Vue.use(Vuex)
Vue.prototype.$ajax = axios;

export default new Vuex.Store({
    state:{
        iflogin:true, //判断是否登录,
        ifsearch:0, //是否点击搜索贴吧
        followList:[{
            id:1
        }]
    },
    mutations:{
        setiflogin(state,data){
            state.iflogin = data;
        },
        setifsearch(state,data){
            
            state.ifsearch = state.ifsearch + 1;
            console.log(state.ifsearch)
        },
        //获取我关注的人列表
        getfollowee(state){
            state.followList = []
            console.log('获取关注列表')
            let loginMember = Tool.getLoginMember();
            console.log(loginMember)

            let userId=loginMember.id;
            Vue.prototype.$ajax.post(process.env.VUE_APP_SERVER + '/business/web/followees/'+userId, {
                page: 1,
                size: 10000,
            }).then((response)=>{
                console.log("查询我关注的人列表结果：", response['data']['content']['map']['users']);
                // state.followList =
                const list = response['data']['content']['map']['users'];
                for(let i in list){
                    // console.log(list[i].user)
                    state.followList.push(list[i].user)
                }

            })
        }
    },
    actions:{

    },
    method:{

    }
})
